package com.yf.stat.modules.course.dto.response;

import com.yf.ability.excel.annotation.ExcelField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
* <p>
* 课件统计响应类
* </p>
*
* @author 聪明笨狗
* @since 2020-09-11 11:10
*/
@Data
@ApiModel(value="课件统计响应类", description="课件统计响应类")
public class StatCourseFileDTO implements Serializable {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "ID", required=true)
    private String id;

    @ExcelField(title = "课件名称")
    @ApiModelProperty(value = "课件名称", required=true)
    private String fileName;

    @ExcelField(title = "学习人数")
    @ApiModelProperty(value = "学习用户")
    private Integer learnUser;

    @ExcelField(title = "学完人数")
    @ApiModelProperty(value = "学完人数")
    private Integer finishUser;

    @ExcelField(title = "学完比率%", sort = 3)
    private Integer passRate;

    /**
     * 学完比率
     * @return
     */
    public Integer getPassRate(){

        // 无人通过
        if(finishUser==null || finishUser.equals(0) || learnUser==null || learnUser==0){
            return 0;
        }

        // 完成用户
        return finishUser*100/learnUser;
    }
}
